#!/bin/sh /etc/rc.common
START=50

run_verysync()
{
	local enabled
	config_get_bool enabled $1 enabled
	if [ $enabled = 1 ]; then
	local port
	config_get port $1 port
	state=`pgrep verysync | wc -l`
	if [ $state = 0 ] ; then
		export HOME="/root"
        verysync -gui-address="0.0.0.0:$port" -logfile="/var/log/verysync.log" -no-browser >/dev/null &
	echo "启动中..."
	start=`pgrep verysync | wc -l`
	if [ $start = 0 ] ; then
	echo "启动失败"
	else
	echo "启动成功"
	fi
	else
	echo "已在运行"
	fi
	fi
}

start()
{
	config_load verysync
	config_foreach run_verysync setting
}

stop()
{
	kill -9 `pgrep verysync`
	stop=`pgrep verysync | wc -l`
	if [ $stop = 0 ] ; then
	echo "已停止运行"
	else
	echo "未停止运行"
	fi
}
